<?php include "classes.inc" ?>
<?php include "constants.inc" ?>
<?php if (!session_id()) session_start(); ?>
<?php

    //include("header_login_required.php");

    //setTabIndex(2);

    //createPage("Liga - Zilveren Toren");

?>

<?php
    if ( isset($_SESSION['user']) ) {
		$user = $_SESSION['user'];

        mysql_connect(DB_SERVER, DB_USER, DB_PWD);
	    mysql_select_db(DB_CATALOG);

	    $result = mysql_query("select count(1) as nrOfTeams from zt_team te 
	    	join zt_tournament t on t.tournament_id = te.tournament_id 
	    	where t.iscurrent = 1 and club_id = ".$user->club_id);
	    $row = mysql_fetch_assoc($result);
        $nrOfTeams = $row['nrOfTeams'];
        if ($nrOfTeams == 0) {
			$msg = "U moet eerst het aantal ploegen opgeven ".$nrOfTeams;
			redirect("/tornooien/zt-php/view_players_list.php?msg=".$msg);
        }
	}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Tornooien</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../../assets/css/default.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../../assets/js/ajax.js" />
</script>
</head>

<body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0" class="default">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td>
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="7">
                        <img src="../../assets/images/spacer.gif" height="1" width="7" ALT="">
                    </td>
                    <td width="150" align="left"><img src="../../assets/images/headerbar_kerst.gif" alt="" ></td>

                </tr>
                <tr>
                    <td colspan="2" height="12"><img src="../../assets/images/spacer.gif" alt="" height="12" width="1"></td>
                </tr>
            </table>
        </td>
        <td align="right" valign="top">
		<br/>
<?php
    /*if ( isset($_SESSION['players']) ) {
        $playersListInsert = $_SESSION['players'];
    } else {
    	$playersListInsert = array();
    }*/

    if ( isset($user) ) {
?>
			<a href="../../logout.php?redirect=/tornooien/zt-php/view_players_list.php"><img src="../../assets/images/24x24/plain/exit.gif" border="0" alt="Log uit"></a>
			<br>&nbsp;<br>
			<span class="headerSmall">User <?=$_SESSION['user']->name?> logged in at <?=$user->login_date?>.</span>

<?php
		$action = null;
        if ( isset($_GET['action']) == true ) $action = $_GET['action'];

        mysql_connect(DB_SERVER, DB_USER, DB_PWD);
	    mysql_select_db(DB_CATALOG);

        if ( isset($_SESSION['players']) && $action != 'reset' ) {
        	$playersListInsert = $_SESSION['players'];
        	if ( isset($_GET['row']) == true ) {
            	$row = $_GET['row'];
                if ($action == 'remove') {
	            	array_deleteobj($playersListInsert, $row - 1);
	            } else if ($action == 'up') {
	            	array_switchobj($playersListInsert, $row - 2, $row - 1);
	            } else if ($action == 'down') {
                    array_switchobj($playersListInsert, $row - 1, $row);
	            }
	            $_SESSION['players'] = $playersListInsert;
            }

        } else {
            $result = mysql_query("select pl.* from zt_player_list pl 
            	join zt_tournament t on t.tournament_id = pl.tournament_id 
            	where t.iscurrent = 1 and club_id =".$user->club_id);
        	if (mysql_num_rows($result) == 0) {
	            // insert the player list based on the club elo list
	            $result = mysql_query("select matricule, club, matricule, nom_prenom, sexe, date_naiss, elo_calcul, part_calcu
	                from playernew where club = ".$user->club_id." and suppress = 0 order by elo_calcul desc");

                $playersListInsert = array();
	            $index = 0;
	            while ($row = mysql_fetch_assoc($result)) {
	                if (!isset($playerId) || $playerId != $row['matricule']) {
	                    $playerId = $row['matricule'];
	                    $player = new Player;
	                    $player->player_id = $row['matricule'];
	                    $player->club_id = $row['club'];
	                    $player->player_key = $row['matricule'];
	                    $player->player_name = $row['nom_prenom'];
	                    $player->gender = $row['sexe'];
	                    $player->dob = $row['date_naiss'];
	                    $player->elo = $row['elo_calcul'];
	                    $player->game_count = $row['part_calcu'];
	                    $playersListInsert[$index++] = $player;
	                }
	            }
	            $_SESSION['players'] = $playersListInsert;
	        } else {
            	$msg = "U heeft reeds een spelerslijst.";
	        	redirect("/tornooien/zt-php/view_players_list.php?msg=".$msg);
            }
        }

        $result = mysql_query("SELECT clubname from club where club_id = ".$user->club_id);
		$row = mysql_fetch_assoc($result);
		$clubname = $row['clubname'];
		mysql_free_result($result);
	} else {
	    if ( isset($_POST['username']) && isset($_POST['password']) ) {
	        $username = $_POST['username'];
	        $password = $_POST['password'];

            mysql_connect(DB_SERVER, DB_USER, DB_PWD);
			mysql_select_db(DB_CATALOG);
            $query = sprintf("SELECT user_id, club_id FROM user WHERE (zt_captain = 1 OR club_id = 100) AND username = '%s' AND password = '%s'",
            mysql_real_escape_string($username), mysql_real_escape_string($password));
			$result = mysql_query($query);
	        $num_rows = mysql_num_rows($result);

	        if ($num_rows == 1) {
				$user = new User($username);
				$row = mysql_fetch_assoc($result);
				$user->user_id = $row['user_id'];
				$user->club_id = $row['club_id'];
	        	$_SESSION['user'] = $user;
?>
                <a href="../../logout.php?redirect=/tornooien/zt-php/view_players_list.php"><img src="../../assets/images/24x24/plain/exit.gif" border="0" alt="Log uit"></a>
				<br>&nbsp;<br>
				<span class="headerSmall">User <?=$_SESSION['user']->name?> logged in at <?=$user->login_date?>.</span>
                <!--<META HTTP-EQUIV="refresh" content="1;URL=".HOST."tornooien/zt-php/insert_player_list.php">-->
<?
			} else {
?>
            <span class="headerSmall" style="color:#FFFFCC">Gebruikersnaam '<?=$username?>' en/of paswoord ongeldig, probeer opnieuw.</span>
            <form name="login" action="" method="post" class="login">
				<input id="username" name="username" type="text" size="20" value="gebruikersnaam"
					onFocus="javascript:document.getElementById('username').value=''" />
				<input id="password" name="password" type="password" size="20" value="paswoord"
					onFocus="javascript:document.getElementById('password').value=''" />
				<input type="submit" value="inloggen" />
			</form>
<?php
            }

            mysql_free_result($result);

	    } else {
?>
			<form name="login" action="" method="post" class="login">
				<input id="username" name="username" type="text" size="20" value="gebruikersnaam"
					onFocus="javascript:document.getElementById('username').value=''" />
				<input id="password" name="password" type="password" size="20" value="paswoord"
					onFocus="javascript:document.getElementById('password').value=''" />
				<input type="submit" value="inloggen" />
			</form>
<?php
        }
	}
?>
</td>
		<td>&nbsp;</td>
	</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%" >
    <tr>
        <td align="left">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td rowspan="2" width="7"><img src="../../assets/images/spacer.gif" alt="" height="1" width="7"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
					<td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/newsbox.php" target="_top"><span class="tabName">Nieuwsbox</span></a></td>
					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
					<td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_FFFFFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="activeSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/tornooien/tornooien.html" target="_top"><span class="tabName">Tornooien</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_FFFFFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/bestuur/bestuur.php" target="_top"><span class="tabName">Bestuur</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/advalvas/index.html" target="_top"><span class="tabName">Ad Valvas</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="http://www.frbe-kbsb.be/EloHist/FRBE_Fiche.php" target="_blank"><span class="tabName">ELO</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/clubs/clubs.php" target="_top"><span class="tabName">Clubs</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/jeugd/index.html" target="_top"><span class="tabName">Jeugd</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/links/index.php" target="_top"><span class="tabName">Links</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>
				</tr>
				<tr>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="activeSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="activeSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td width="100%" bgcolor="#FFFFFF" colspan="13"><img border="0" width="30" src="../../assets/images/FFFFFF.gif" height="12" alt=""></td>
	</tr>
</table>

<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0" bgcolor="#FFFFFF">
	<tr>
		<td id="leftFiller" valign="top" height="100%" rowspan="3" bgcolor="#666666">
			<table border="0" cellpadding="0" cellspacing="0" height="100%" width="8px">
				<tr><td>&nbsp;</td></tr>
			</table>
		</td>
		<td id="header" valign="top" width="100%">
			<table border="0" width="100%" cellpadding="3" cellspacing="0" bgcolor="#10425b">
                <tr>
                    <td bgcolor="#666666" width="40%">
                        <?php include("inc_title.html"); ?>
                    </td>
                    <td bgcolor="#666666" align="right" valign="top">&nbsp;
                          <span class="headerSmall">Huidige versie PLAYER.DBF: <?=CURRENT_PLAYER_DBF?>
                        <?php
                        if (isset($user) && $user->club_id == 100) {
                        ?>
                        <br/>
                        <a class="headerSmall" href="import_player.php">laad andere versie</a>
                        <?php
                        }
                        ?>
                        </span>
                    </td>
                </tr>
            </table>
            <table align="center" border="0" width="100%" height="90%" cellpadding="0" cellspacing="0" style="border-top:#BCDD10 4px solid;">
                <tr>
                    <?php include("inc_sublinks.php"); ?> 
                </tr>
				<tr><td colspan="2" nowrap bgcolor="#BCDD10" height="4"><img src="../../assets/images/spacer.gif" alt="" height="1" width="1"></td></tr>
				<tr>
					<td>&nbsp;</td>
					<td valign="top">
						<table align="left" cellspacing="10" width="100%">
							<tr>
								<td>
                                    <?php
                                    	if (isset($user)) {
                                    ?>
                                    <span class="blackHeaderLarge"><?=CURRENT_ZT_TOURNAMENT?> - Invoer spelerslijst <?=$clubname?></span>
									<br>&nbsp;<br>
                                    <a href="view_players_list.php"><img src="../../assets/images/24x24/shadow/document.gif" border="0" alt="Ga naar overzicht spelerslijsten"/>
                                    &nbsp;&nbsp;
                                    <a href="insert_player_list.php?action=reset"><img src="../../assets/images/24x24/shadow/recycle.gif" border="0" alt="Reset spelerslijst"/>
                                    &nbsp;&nbsp;
                                    <a href="validate_player_list.php"><img src="../../assets/images/24x24/shadow/document_check.gif" border="0" alt="Valideer spelerslijst"/>
                                    <span class="hidden" id="noKeyFound">Stamnummer niet gevonden.</span>
                                    <span class="hidden" id="noValidTeam">Ploegnummertoewijzing is niet geldig voor deze speler.</span>
                                    <span class="hidden" id="playerNameIsFixed">Naam van speler mag niet gewijzigd worden.</span>
                                    <span class="hidden" id="playerEloIsInvalid">ELO-waarde is geen geldig getal.</span>
                                    <span class="hidden" id="playerEloIsFixed">ELO voor bestaande speler kan niet gewijzigd worden.</span>
                                    <span class="hidden" id="playerClubIsInvalid">Clubnummer ongeldig of onbestaand.</span>
                                    <span class="hidden" id="playerClubIsFixed">Clubnummer van bestaande speler mag niet gewijzigd worden.</span>
                                    <br>&nbsp;<br>
                                    <table width="70%" border="0" cellpadding="0" cellspacing="0" id="test">
                                        <tr>
											<td width="5%"><strong>Volgnr</strong></td>
											<td width="10%" align="center"><strong>Stamnr</strong>&nbsp;&nbsp;</td>
											<td width="5%" align="center"><strong>Ploegnr</strong></td>
											<td width="60%"><strong>Naam</strong></td>
											<td width="10%" align="center"><strong>ELO</strong></td>
											<td width="10%" align="center"><strong>Kring</strong></td>
											<td>&nbsp;</td>
											<td>&nbsp;</td>
											<td>&nbsp;</td>
											<td>&nbsp;</td>
											<td>&nbsp;</td>
										</tr>
										<form id="playerListForm" action="validate_player_list.php" method="POST">
										<?php
                                            if (count($playersListInsert) == 0) {
                                            	$indexNr = 0;
                                        ?>
                                                <tr>
                                                   <td align="center"><strong><?=$indexNr + 1?></strong></td>
                                                   <td class="clsTableInputForm" align="center"><input size="10"  name="playerKey_<?=$indexNr + 1?>" class="clsInputForm" onblur="getPlayer(this.value,<?=$indexNr + 1?>,'', '', '')"></td>
                                                   <td class="clsTableInputForm" align="center"><input size="10"  name="teamName_<?=$indexNr + 1?>" class="clsInputForm" value="&nbsp;" onblur="storePlayerTeam(this.value,'','',<?=$indexNr + 1?>,'')"/></td>
                                                   <td class="clsTableInputForm"><input size="45" style="text-align:left" name="playerName_<?=$indexNr + 1?>" class="clsInputForm" onblur="storePlayerName(this.value,<?=$indexNr + 1?>,'')"/></td>
                                                   <td class="clsTableInputForm" align="center"><input size="10"  name="playerElo_<?=$indexNr + 1?>" class="clsInputForm" onblur="storePlayerElo(this.value,<?=$indexNr + 1?>,'')"/></td>
                                                   <td class="clsTableInputForm" align="center"><input size="10"  name="playerClub_<?=$indexNr + 1?>" class="clsInputForm" onblur="storePlayerClub(this.value,<?=$indexNr + 1?>,'')"/></td>
                                                   <td class="clsTableInputForm">&nbsp;</td>
                                                   <td class="clsTableInputForm">&nbsp;&nbsp;<a href="insert_player_list.php?row=<?=$indexNr + 1?>&action=remove"><img border="0" src="../../assets/images/16x16/shadow/delete2.gif"></a></td>
                                                   <td class="clsTableInputForm">&nbsp;</td>
                                                   <td class="clsTableInputForm">&nbsp;</td>
                                                   <td class="clsTableInputForm">&nbsp;&nbsp;<a href="insert_player_list.php?row=<?=$indexNr + 2?>&action=add"><img border="0" src="../../assets/images/16x16/shadow/add2.gif"></a></td>
                                               </tr>
                                        <?php
                                            }

                                            $row = null;
	                                        if ( isset($_GET['row']) == true ) $row = $_GET['row'];

	                                        while ($player = current($playersListInsert)) {
	                                           $indexNr = key($playersListInsert);
	                                           if ($row == $indexNr + 1) { // row equals the current player
	                                               if ($action == 'insert') {
	                                                   $emptyPlayer = New Player;
	                                                   $emptyPlayer->playerKey = null;
	                                                   $emptyPlayer->name = null;
	                                                   $emptyPlayer->elo = null;
                                               ?>
                                               <tr>
                                                   <td align="center"><strong><?=$indexNr + 1?></strong></td>
                                                   <td class="clsTableInputForm" align="center"><input size="10" name="playerKey_<?=$indexNr + 1?>" class="clsInputForm" onblur="getPlayer(this.value,<?=$indexNr + 1?>,'', '', '')"></td>
                                                   <td class="clsTableInputForm" align="center"><input size="10" name="teamName_<?=$indexNr + 1?>" class="clsInputForm" onblur="storePlayerTeam(this.value,'','',<?=$indexNr + 1?>,'')"/></td>
                                                   <td><span class="hidden" id="playerName_<?=$indexNr + 1?>" name="playerName_<?=$indexNr + 1?>"></span></td>
			                                       <td align="center"><span class="hidden" id="playerElo_<?=$indexNr + 1?>" name="playerElo_<?=$indexNr + 1?>"></span></td>
			                                       <td align="center"><span class="hidden" id="playerClub_<?=$indexNr + 1?>" name="playerClub_<?=$indexNr + 1?>"></span></td>
                                                   <td>&nbsp;</td>
                                                   <td>&nbsp;&nbsp;<a href="insert_player_list.php?row=<?=$indexNr + 1?>&action=remove"><img border="0" src="../../assets/images/16x16/shadow/arrow_right_blue.gif"></a></td>
                                                   <td>&nbsp;</td>
                                                   <td>&nbsp;</td>
                                                   <td>&nbsp;</td>
                                               </tr>
                                               <?php
                                                           // since the inserted value is an object we have to treat it differently,
                                                           array_insertobj($playersListInsert, $indexNr, $emptyPlayer);
                                                           $_SESSION['players'] = $playersListInsert;
                                                           // the function went to the beginning of the array when done, so go to the correct current
                                                           // position
                                                           for ($i = 0; $i < $row; $i++) {
                                                              next($playersListInsert);
                                                           }
                                                       }
                                                   }
                                        	    ?>
	                                            <tr>
	                                                <td align="center"><strong><?=key($playersListInsert) + 1?></strong></td>
	                                                <td class="clsTableInputForm" align="center"><input size="10" name="playerKey_<?=key($playersListInsert) + 1?>" class="clsInputForm" value="<?=$player->player_key?>"></td>
	                                                <td class="clsTableInputForm" align="center"><input size="10" name="teamName_<?=key($playersListInsert) + 1?>" class="clsInputForm" value="<?=$player->team_name?>"  onblur="storePlayerTeam(this.value,'','',<?=$indexNr + 1?>,'')" /></td>
	                                                <td><span class="default" id="playerName_<?=key($playersListInsert) + 1?>" name="playerName_<?=key($playersListInsert) + 1?>">&nbsp;&nbsp;<?=$player->player_name?></span></td>
					                                <td><span class="default" id="playerElo_<?=key($playersListInsert) + 1?>" name="playerElo_<?=key($playersListInsert) + 1?>">&nbsp;&nbsp;<?=$player->elo?></span></td>
					                                <td><span class="default" id="playerClub_<?=key($playersListInsert) + 1?>" name="playerClub_<?=key($playersListInsert) + 1?>">&nbsp;&nbsp;<?=$player->club_id?></span></td>
	                                                <td align="center">&nbsp;&nbsp;<a href="insert_player_list.php?row=<?=$indexNr + 1?>&action=insert"><img border="0" src="../../assets/images/16x16/shadow/arrow_left_green.gif"></a></td>
	                                                <td align="center">&nbsp;&nbsp;<a href="insert_player_list.php?row=<?=$indexNr + 1?>&action=remove"><img border="0" src="../../assets/images/16x16/shadow/delete2.gif"></a></td>
                                                    <?php
	                                            	if($indexNr != 0) { // first row
	                                            ?>
	                                                <td align="center">&nbsp;&nbsp;<a href="insert_player_list.php?row=<?=$indexNr + 1?>&action=up"><img border="0" src="../../assets/images/16x16/shadow/arrow_up_green.gif"></a></td>
	                                            <?php
	                                            	} else {
                                                ?>
                                                    <td>&nbsp;</td>
                                                <?php
                                                    }
	                                            	if($indexNr + 1 != count($playersListInsert)) { // row is not last row
	                                            ?>
	                                                <td align="center">&nbsp;&nbsp;<a href="insert_player_list.php?row=<?=$indexNr + 1?>&action=down"><img border="0" src="../../assets/images/16x16/shadow/arrow_down_blue.gif"></a></td>
	                                            <?php
	                                            	} else {
                                                ?>
                                                    <td>&nbsp;</td>
                                                <?php
                                                    }
	                                            	if($indexNr + 1 == count($playersListInsert) && $action != 'add') { // row is last row
	                                            ?>
	                                                <td>&nbsp;&nbsp;<a href="insert_player_list.php?row=<?=$indexNr + 2?>&action=add"><img border="0" src="../../assets/images/16x16/shadow/add2.gif"></a></td>
	                                            <?php
	                                            	}
	                                            ?>
	                                            </tr>
	                                    <?php
	                                    			if ($action == 'add' && $indexNr + 1 == count($playersListInsert) && $row == $indexNr + 2) {
                                                        $emptyPlayer = New Player;
                                                        $emptyPlayer->playerKey = null;
                                                        $emptyPlayer->name = null;
                                                        $emptyPlayer->elo = null;
                                                    ?>
                                               <tr>
                                                   <td align="center"><strong><?=$indexNr + 2?></strong></td>
                                                   <td class="clsTableInputForm" align="center"><input size="10"  name="playerKey_<?=$indexNr + 2?>" class="clsInputForm" onblur="getPlayer(this.value,<?=$indexNr + 2?>,'', '', '')"></td>
                                                   <td class="clsTableInputForm" align="center"><input size="10"  name="teamName_<?=$indexNr + 2?>" class="clsInputForm" value="&nbsp;" onblur="storePlayerTeam(this.value,'','',<?=$indexNr + 2?>,'')"/></td>
                                                   <td><span class="default" id="playerName_<?=$indexNr + 2?>" name="playerName_<?=$indexNr + 2?>"></span></td>
				                                   <td align="center"><span class="default" id="playerElo_<?=$indexNr + 2?>" name="playerElo_<?=$indexNr + 2?>"></span></td>
				                                   <td align="center"><span class="default" id="playerClub_<?=$indexNr + 2?>" name="playerClub_<?=$indexNr + 2?>"></span></td>
                                                   <td>&nbsp;</td>
                                                   <td>&nbsp;&nbsp;<a href="insert_player_list.php?row=<?=$indexNr + 2?>&action=remove"><img border="0" src="../../assets/images/16x16/shadow/arrow_right_blue.gif"></a></td>
                                                   <td>&nbsp;</td>
                                                   <td>&nbsp;</td>
                                                   <td>&nbsp;&nbsp;<a href="insert_player_list.php?row=<?=$indexNr + 3?>&action=add"><img border="0" src="../../assets/images/16x16/shadow/add2.gif"></a></td>
                                               </tr>
                                               <?php
                                                    array_addobj($playersListInsert, $emptyPlayer);
	                                                $_SESSION['players'] = $playersListInsert;
	                                                prev($playersListInsert);
	                                            }

	                                            next($playersListInsert);
	                                        }

										?>
										<tr>
											<td colspan="11">&nbsp;</td>
										</tr>
										</form>
									</table>
                                    <?php
                                        } else {
                                    ?>
                                    <span class="blackHeaderLarge"><?=CURRENT_ZT_TOURNAMENT?> - Invoer spelerslijst</span>
									<br>&nbsp;<br>
									<strong>U moet ingelogd zijn om een spelerslijst te kunnen invoeren.</strong>
                                    <?php
                                        }
									?>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
			</table>
		</td>
	</tr>
</table>

</body>
</html>
